/*
 * @lc app=leetcode.cn id=705 lang=typescript
 *
 * [705] 设计哈希集合
 */

// @lc code=start
class MyHashSet {
    constructor() {}
    cache: number[] = [];
    add(key: number): void {
        if (!this.contains(key)) {
            this.cache.push(key);
        }
    }

    remove(key: number): void {
        const index = this.cache.findIndex((i) => i === key);
        if (index !== -1) {
            this.cache.splice(
                this.cache.findIndex((i) => i === key),
                1
            );
        }
    }

    contains(key: number): boolean {
        return this.cache.includes(key);
    }
}

/**
 * Your MyHashSet object will be instantiated and called as such:
 * var obj = new MyHashSet()
 * obj.add(key)
 * obj.remove(key)
 * var param_3 = obj.contains(key)
 */
// @lc code=end
